using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using ADODB;
using PKMCDO;
using SharePoint.ImportExport.Core;
using System.Reflection;
using System.Runtime.InteropServices;
using SharePoint.ImportExport.ExportSPS2001.ExportData;
using System.Security.Principal;
namespace SharePoint.ImportExport.ExportSPS2001

{
	/// <summary>
	/// Summary description for MainApp.
	/// </summary>
	public class frmExporter : System.Windows.Forms.Form
	{
		public System.Windows.Forms.PictureBox Picture1;
		public System.Windows.Forms.PictureBox TopBanner;
		public System.Windows.Forms.ToolTip ToolTip1;
		private System.Windows.Forms.TabPage tab_Source;
		private System.Windows.Forms.TabPage tab_Destination;
		private System.Windows.Forms.TabControl tabControl1;
		private System.Windows.Forms.TabPage tabPage1;
		private System.Windows.Forms.TabPage tabPage2;
		public System.Windows.Forms.GroupBox Frame2;
		public System.Windows.Forms.RadioButton optAllInSameFolder;
		public System.Windows.Forms.RadioButton optFolderPreProfile;
		public System.Windows.Forms.TextBox txtEMail;
		public System.Windows.Forms.TextBox txtOwner;
		public System.Windows.Forms.ComboBox cmbRoot;
		public System.Windows.Forms.Label Label10;
		public System.Windows.Forms.Label Label7;
		public System.Windows.Forms.Label Label9;
		private System.Windows.Forms.TabPage tabPage3;
		private System.Windows.Forms.GroupBox groupBox1;
		public System.Windows.Forms.CheckBox chkMigrateVersions;
		private System.Windows.Forms.GroupBox groupBox2;
		public System.Windows.Forms.TextBox txtSPS2001RootFolder;
		public System.Windows.Forms.TextBox txtWorkSpace;
		public System.Windows.Forms.Label Label2;
		public System.Windows.Forms.Label Workspace;
		private System.Windows.Forms.Button btnNext1;
		private System.Windows.Forms.Button btnNext2;
		private System.Windows.Forms.Button btnClose;
		private System.Windows.Forms.Button btnStart;
		private System.Windows.Forms.RichTextBox rtb_EventLog;
		private System.Windows.Forms.Button btnPick;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.TextBox txtSiteDefinitionName;
		public System.Windows.Forms.TextBox txtDirPath;
		public System.Windows.Forms.Label Label1;
        private System.Windows.Forms.Label lblProfileToUse;
        public RadioButton optUseMultipleProfiles;
        private TextBox txtSiteName;
        private Label label4;
        private GroupBox groupBox3;
        private RadioButton rdReportAll;
        private RadioButton rdReportWarnings;
        private RadioButton rdReportErrors;
        private Button btnPopulate;
        private ComboBox cmbDocumentProfiles;
		private System.ComponentModel.IContainer components;

		public frmExporter()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmExporter));
            this.Picture1 = new System.Windows.Forms.PictureBox();
            this.TopBanner = new System.Windows.Forms.PictureBox();
            this.ToolTip1 = new System.Windows.Forms.ToolTip(this.components);
            this.tab_Source = new System.Windows.Forms.TabPage();
            this.tab_Destination = new System.Windows.Forms.TabPage();
            this.tabControl1 = new System.Windows.Forms.TabControl();
            this.tabPage1 = new System.Windows.Forms.TabPage();
            this.btnNext1 = new System.Windows.Forms.Button();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.btnPick = new System.Windows.Forms.Button();
            this.txtSPS2001RootFolder = new System.Windows.Forms.TextBox();
            this.txtWorkSpace = new System.Windows.Forms.TextBox();
            this.Label2 = new System.Windows.Forms.Label();
            this.Workspace = new System.Windows.Forms.Label();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.txtDirPath = new System.Windows.Forms.TextBox();
            this.Label1 = new System.Windows.Forms.Label();
            this.chkMigrateVersions = new System.Windows.Forms.CheckBox();
            this.tabPage2 = new System.Windows.Forms.TabPage();
            this.lblProfileToUse = new System.Windows.Forms.Label();
            this.txtSiteName = new System.Windows.Forms.TextBox();
            this.label4 = new System.Windows.Forms.Label();
            this.txtSiteDefinitionName = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.btnNext2 = new System.Windows.Forms.Button();
            this.txtEMail = new System.Windows.Forms.TextBox();
            this.txtOwner = new System.Windows.Forms.TextBox();
            this.cmbRoot = new System.Windows.Forms.ComboBox();
            this.Label10 = new System.Windows.Forms.Label();
            this.Label7 = new System.Windows.Forms.Label();
            this.Label9 = new System.Windows.Forms.Label();
            this.Frame2 = new System.Windows.Forms.GroupBox();
            this.optAllInSameFolder = new System.Windows.Forms.RadioButton();
            this.optUseMultipleProfiles = new System.Windows.Forms.RadioButton();
            this.optFolderPreProfile = new System.Windows.Forms.RadioButton();
            this.tabPage3 = new System.Windows.Forms.TabPage();
            this.rtb_EventLog = new System.Windows.Forms.RichTextBox();
            this.btnStart = new System.Windows.Forms.Button();
            this.btnClose = new System.Windows.Forms.Button();
            this.groupBox3 = new System.Windows.Forms.GroupBox();
            this.rdReportAll = new System.Windows.Forms.RadioButton();
            this.rdReportWarnings = new System.Windows.Forms.RadioButton();
            this.rdReportErrors = new System.Windows.Forms.RadioButton();
            this.cmbDocumentProfiles = new System.Windows.Forms.ComboBox();
            this.btnPopulate = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.Picture1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.TopBanner)).BeginInit();
            this.tabControl1.SuspendLayout();
            this.tabPage1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.groupBox1.SuspendLayout();
            this.tabPage2.SuspendLayout();
            this.Frame2.SuspendLayout();
            this.tabPage3.SuspendLayout();
            this.groupBox3.SuspendLayout();
            this.SuspendLayout();
            // 
            // Picture1
            // 
            this.Picture1.BackColor = System.Drawing.SystemColors.Window;
            this.Picture1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.Picture1.Cursor = System.Windows.Forms.Cursors.Default;
            this.Picture1.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Picture1.ForeColor = System.Drawing.SystemColors.WindowText;
            this.Picture1.Image = ((System.Drawing.Image)(resources.GetObject("Picture1.Image")));
            this.Picture1.Location = new System.Drawing.Point(0, 672);
            this.Picture1.Name = "Picture1";
            this.Picture1.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.Picture1.Size = new System.Drawing.Size(601, 65);
            this.Picture1.TabIndex = 56;
            this.Picture1.TabStop = false;
            // 
            // TopBanner
            // 
            this.TopBanner.BackColor = System.Drawing.SystemColors.Window;
            this.TopBanner.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            this.TopBanner.Cursor = System.Windows.Forms.Cursors.Default;
            this.TopBanner.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.TopBanner.ForeColor = System.Drawing.SystemColors.WindowText;
            this.TopBanner.Image = ((System.Drawing.Image)(resources.GetObject("TopBanner.Image")));
            this.TopBanner.Location = new System.Drawing.Point(0, 0);
            this.TopBanner.Name = "TopBanner";
            this.TopBanner.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.TopBanner.Size = new System.Drawing.Size(601, 65);
            this.TopBanner.TabIndex = 55;
            this.TopBanner.TabStop = false;
            // 
            // tab_Source
            // 
            this.tab_Source.Location = new System.Drawing.Point(4, 25);
            this.tab_Source.Name = "tab_Source";
            this.tab_Source.Size = new System.Drawing.Size(400, 67);
            this.tab_Source.TabIndex = 0;
            this.tab_Source.Text = "Source";
            // 
            // tab_Destination
            // 
            this.tab_Destination.Location = new System.Drawing.Point(4, 25);
            this.tab_Destination.Name = "tab_Destination";
            this.tab_Destination.Size = new System.Drawing.Size(400, 67);
            this.tab_Destination.TabIndex = 1;
            this.tab_Destination.Text = "Destination";
            // 
            // tabControl1
            // 
            this.tabControl1.Controls.Add(this.tabPage1);
            this.tabControl1.Controls.Add(this.tabPage2);
            this.tabControl1.Controls.Add(this.tabPage3);
            this.tabControl1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.tabControl1.Location = new System.Drawing.Point(0, 72);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new System.Drawing.Size(600, 360);
            this.tabControl1.TabIndex = 61;
            this.tabControl1.SelectedIndexChanged += new System.EventHandler(this.tabControl1_SelectedIndexChanged);
            // 
            // tabPage1
            // 
            this.tabPage1.Controls.Add(this.groupBox3);
            this.tabPage1.Controls.Add(this.btnNext1);
            this.tabPage1.Controls.Add(this.groupBox2);
            this.tabPage1.Controls.Add(this.groupBox1);
            this.tabPage1.Location = new System.Drawing.Point(4, 22);
            this.tabPage1.Name = "tabPage1";
            this.tabPage1.Size = new System.Drawing.Size(592, 334);
            this.tabPage1.TabIndex = 0;
            this.tabPage1.Text = "Source";
            // 
            // btnNext1
            // 
            this.btnNext1.BackColor = System.Drawing.SystemColors.HotTrack;
            this.btnNext1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnNext1.ForeColor = System.Drawing.SystemColors.Menu;
            this.btnNext1.Location = new System.Drawing.Point(480, 296);
            this.btnNext1.Name = "btnNext1";
            this.btnNext1.Size = new System.Drawing.Size(96, 24);
            this.btnNext1.TabIndex = 68;
            this.btnNext1.Text = "&Next";
            this.btnNext1.UseVisualStyleBackColor = false;
            this.btnNext1.Click += new System.EventHandler(this.btnNext1_Click);
            // 
            // groupBox2
            // 
            this.groupBox2.Controls.Add(this.btnPick);
            this.groupBox2.Controls.Add(this.txtSPS2001RootFolder);
            this.groupBox2.Controls.Add(this.txtWorkSpace);
            this.groupBox2.Controls.Add(this.Label2);
            this.groupBox2.Controls.Add(this.Workspace);
            this.groupBox2.Location = new System.Drawing.Point(8, 8);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(576, 93);
            this.groupBox2.TabIndex = 67;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "Source";
            // 
            // btnPick
            // 
            this.btnPick.Location = new System.Drawing.Point(512, 56);
            this.btnPick.Name = "btnPick";
            this.btnPick.Size = new System.Drawing.Size(45, 23);
            this.btnPick.TabIndex = 68;
            this.btnPick.Text = "&Pick";
            this.btnPick.Click += new System.EventHandler(this.btnPick_Click);
            // 
            // txtSPS2001RootFolder
            // 
            this.txtSPS2001RootFolder.AcceptsReturn = true;
            this.txtSPS2001RootFolder.BackColor = System.Drawing.SystemColors.Window;
            this.txtSPS2001RootFolder.Cursor = System.Windows.Forms.Cursors.IBeam;
            this.txtSPS2001RootFolder.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtSPS2001RootFolder.ForeColor = System.Drawing.SystemColors.WindowText;
            this.txtSPS2001RootFolder.Location = new System.Drawing.Point(111, 53);
            this.txtSPS2001RootFolder.MaxLength = 0;
            this.txtSPS2001RootFolder.Name = "txtSPS2001RootFolder";
            this.txtSPS2001RootFolder.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.txtSPS2001RootFolder.Size = new System.Drawing.Size(400, 20);
            this.txtSPS2001RootFolder.TabIndex = 65;
            this.txtSPS2001RootFolder.Text = "/Documents";
            // 
            // txtWorkSpace
            // 
            this.txtWorkSpace.AcceptsReturn = true;
            this.txtWorkSpace.BackColor = System.Drawing.SystemColors.Window;
            this.txtWorkSpace.Cursor = System.Windows.Forms.Cursors.IBeam;
            this.txtWorkSpace.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtWorkSpace.ForeColor = System.Drawing.SystemColors.WindowText;
            this.txtWorkSpace.Location = new System.Drawing.Point(111, 21);
            this.txtWorkSpace.MaxLength = 0;
            this.txtWorkSpace.Name = "txtWorkSpace";
            this.txtWorkSpace.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.txtWorkSpace.Size = new System.Drawing.Size(400, 20);
            this.txtWorkSpace.TabIndex = 64;
            // 
            // Label2
            // 
            this.Label2.BackColor = System.Drawing.SystemColors.Control;
            this.Label2.Cursor = System.Windows.Forms.Cursors.Default;
            this.Label2.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Label2.ForeColor = System.Drawing.SystemColors.ControlText;
            this.Label2.Location = new System.Drawing.Point(8, 53);
            this.Label2.Name = "Label2";
            this.Label2.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.Label2.Size = new System.Drawing.Size(88, 25);
            this.Label2.TabIndex = 67;
            this.Label2.Text = "From folder";
            // 
            // Workspace
            // 
            this.Workspace.BackColor = System.Drawing.SystemColors.Control;
            this.Workspace.Cursor = System.Windows.Forms.Cursors.Default;
            this.Workspace.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Workspace.ForeColor = System.Drawing.SystemColors.ControlText;
            this.Workspace.Location = new System.Drawing.Point(8, 21);
            this.Workspace.Name = "Workspace";
            this.Workspace.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.Workspace.Size = new System.Drawing.Size(97, 17);
            this.Workspace.TabIndex = 66;
            this.Workspace.Text = "Workspace";
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.txtDirPath);
            this.groupBox1.Controls.Add(this.Label1);
            this.groupBox1.Controls.Add(this.chkMigrateVersions);
            this.groupBox1.Location = new System.Drawing.Point(8, 107);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(576, 77);
            this.groupBox1.TabIndex = 66;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "Migration Options";
            // 
            // txtDirPath
            // 
            this.txtDirPath.AcceptsReturn = true;
            this.txtDirPath.BackColor = System.Drawing.SystemColors.Window;
            this.txtDirPath.Cursor = System.Windows.Forms.Cursors.IBeam;
            this.txtDirPath.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtDirPath.ForeColor = System.Drawing.SystemColors.WindowText;
            this.txtDirPath.Location = new System.Drawing.Point(111, 43);
            this.txtDirPath.MaxLength = 0;
            this.txtDirPath.Name = "txtDirPath";
            this.txtDirPath.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.txtDirPath.Size = new System.Drawing.Size(467, 20);
            this.txtDirPath.TabIndex = 65;
            // 
            // Label1
            // 
            this.Label1.BackColor = System.Drawing.SystemColors.Control;
            this.Label1.Cursor = System.Windows.Forms.Cursors.Default;
            this.Label1.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Label1.ForeColor = System.Drawing.SystemColors.ControlText;
            this.Label1.Location = new System.Drawing.Point(8, 48);
            this.Label1.Name = "Label1";
            this.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.Label1.Size = new System.Drawing.Size(97, 15);
            this.Label1.TabIndex = 66;
            this.Label1.Text = "Export Directory";
            // 
            // chkMigrateVersions
            // 
            this.chkMigrateVersions.BackColor = System.Drawing.SystemColors.Control;
            this.chkMigrateVersions.Cursor = System.Windows.Forms.Cursors.Default;
            this.chkMigrateVersions.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.chkMigrateVersions.ForeColor = System.Drawing.SystemColors.ControlText;
            this.chkMigrateVersions.Location = new System.Drawing.Point(8, 16);
            this.chkMigrateVersions.Name = "chkMigrateVersions";
            this.chkMigrateVersions.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.chkMigrateVersions.Size = new System.Drawing.Size(112, 25);
            this.chkMigrateVersions.TabIndex = 26;
            this.chkMigrateVersions.Text = "Migrate versions";
            this.chkMigrateVersions.UseVisualStyleBackColor = false;
            // 
            // tabPage2
            // 
            this.tabPage2.Controls.Add(this.btnPopulate);
            this.tabPage2.Controls.Add(this.cmbDocumentProfiles);
            this.tabPage2.Controls.Add(this.lblProfileToUse);
            this.tabPage2.Controls.Add(this.txtSiteName);
            this.tabPage2.Controls.Add(this.label4);
            this.tabPage2.Controls.Add(this.txtSiteDefinitionName);
            this.tabPage2.Controls.Add(this.label3);
            this.tabPage2.Controls.Add(this.btnNext2);
            this.tabPage2.Controls.Add(this.txtEMail);
            this.tabPage2.Controls.Add(this.txtOwner);
            this.tabPage2.Controls.Add(this.cmbRoot);
            this.tabPage2.Controls.Add(this.Label10);
            this.tabPage2.Controls.Add(this.Label7);
            this.tabPage2.Controls.Add(this.Label9);
            this.tabPage2.Controls.Add(this.Frame2);
            this.tabPage2.Location = new System.Drawing.Point(4, 22);
            this.tabPage2.Name = "tabPage2";
            this.tabPage2.Size = new System.Drawing.Size(592, 334);
            this.tabPage2.TabIndex = 1;
            this.tabPage2.Text = "Destination";
            // 
            // lblProfileToUse
            // 
            this.lblProfileToUse.Enabled = false;
            this.lblProfileToUse.Location = new System.Drawing.Point(8, 163);
            this.lblProfileToUse.Name = "lblProfileToUse";
            this.lblProfileToUse.Size = new System.Drawing.Size(134, 32);
            this.lblProfileToUse.TabIndex = 5;
            this.lblProfileToUse.Text = "Document Profile to Use";
            // 
            // txtSiteName
            // 
            this.txtSiteName.Location = new System.Drawing.Point(157, 101);
            this.txtSiteName.Name = "txtSiteName";
            this.txtSiteName.Size = new System.Drawing.Size(360, 20);
            this.txtSiteName.TabIndex = 2;
            // 
            // label4
            // 
            this.label4.Location = new System.Drawing.Point(8, 104);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(122, 17);
            this.label4.TabIndex = 1;
            this.label4.Text = "Site Name";
            // 
            // txtSiteDefinitionName
            // 
            this.txtSiteDefinitionName.Location = new System.Drawing.Point(157, 197);
            this.txtSiteDefinitionName.Name = "txtSiteDefinitionName";
            this.txtSiteDefinitionName.Size = new System.Drawing.Size(360, 20);
            this.txtSiteDefinitionName.TabIndex = 8;
            this.txtSiteDefinitionName.Text = "STS#0";
            // 
            // label3
            // 
            this.label3.Location = new System.Drawing.Point(8, 200);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(100, 32);
            this.label3.TabIndex = 7;
            this.label3.Text = "Site Definition";
            // 
            // btnNext2
            // 
            this.btnNext2.BackColor = System.Drawing.SystemColors.HotTrack;
            this.btnNext2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnNext2.ForeColor = System.Drawing.SystemColors.Menu;
            this.btnNext2.Location = new System.Drawing.Point(488, 304);
            this.btnNext2.Name = "btnNext2";
            this.btnNext2.Size = new System.Drawing.Size(96, 24);
            this.btnNext2.TabIndex = 13;
            this.btnNext2.Text = "N&ext";
            this.btnNext2.UseVisualStyleBackColor = false;
            this.btnNext2.Click += new System.EventHandler(this.btnNext2_Click);
            // 
            // txtEMail
            // 
            this.txtEMail.AcceptsReturn = true;
            this.txtEMail.BackColor = System.Drawing.SystemColors.Window;
            this.txtEMail.Cursor = System.Windows.Forms.Cursors.IBeam;
            this.txtEMail.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtEMail.ForeColor = System.Drawing.SystemColors.WindowText;
            this.txtEMail.Location = new System.Drawing.Point(157, 261);
            this.txtEMail.MaxLength = 0;
            this.txtEMail.Name = "txtEMail";
            this.txtEMail.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.txtEMail.Size = new System.Drawing.Size(360, 20);
            this.txtEMail.TabIndex = 12;
            // 
            // txtOwner
            // 
            this.txtOwner.AcceptsReturn = true;
            this.txtOwner.BackColor = System.Drawing.SystemColors.Window;
            this.txtOwner.Cursor = System.Windows.Forms.Cursors.IBeam;
            this.txtOwner.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.txtOwner.ForeColor = System.Drawing.SystemColors.WindowText;
            this.txtOwner.Location = new System.Drawing.Point(157, 229);
            this.txtOwner.MaxLength = 0;
            this.txtOwner.Name = "txtOwner";
            this.txtOwner.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.txtOwner.Size = new System.Drawing.Size(360, 20);
            this.txtOwner.TabIndex = 10;
            // 
            // cmbRoot
            // 
            this.cmbRoot.BackColor = System.Drawing.SystemColors.Window;
            this.cmbRoot.Cursor = System.Windows.Forms.Cursors.Default;
            this.cmbRoot.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cmbRoot.ForeColor = System.Drawing.SystemColors.WindowText;
            this.cmbRoot.Items.AddRange(new object[] {
            "Sites",
            "Topics"});
            this.cmbRoot.Location = new System.Drawing.Point(157, 131);
            this.cmbRoot.Name = "cmbRoot";
            this.cmbRoot.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.cmbRoot.Size = new System.Drawing.Size(206, 22);
            this.cmbRoot.Sorted = true;
            this.cmbRoot.TabIndex = 4;
            this.cmbRoot.Text = "Sites";
            // 
            // Label10
            // 
            this.Label10.BackColor = System.Drawing.SystemColors.Control;
            this.Label10.Cursor = System.Windows.Forms.Cursors.Default;
            this.Label10.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Label10.ForeColor = System.Drawing.SystemColors.ControlText;
            this.Label10.Location = new System.Drawing.Point(8, 262);
            this.Label10.Name = "Label10";
            this.Label10.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.Label10.Size = new System.Drawing.Size(88, 32);
            this.Label10.TabIndex = 11;
            this.Label10.Text = "EMail";
            // 
            // Label7
            // 
            this.Label7.BackColor = System.Drawing.SystemColors.Control;
            this.Label7.Cursor = System.Windows.Forms.Cursors.Default;
            this.Label7.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Label7.ForeColor = System.Drawing.SystemColors.ControlText;
            this.Label7.Location = new System.Drawing.Point(8, 230);
            this.Label7.Name = "Label7";
            this.Label7.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.Label7.Size = new System.Drawing.Size(105, 32);
            this.Label7.TabIndex = 9;
            this.Label7.Text = "Owner";
            // 
            // Label9
            // 
            this.Label9.BackColor = System.Drawing.SystemColors.Control;
            this.Label9.Cursor = System.Windows.Forms.Cursors.Default;
            this.Label9.Font = new System.Drawing.Font("Arial", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Label9.ForeColor = System.Drawing.SystemColors.ControlText;
            this.Label9.Location = new System.Drawing.Point(8, 131);
            this.Label9.Name = "Label9";
            this.Label9.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.Label9.Size = new System.Drawing.Size(110, 18);
            this.Label9.TabIndex = 3;
            this.Label9.Text = "Site collection root";
            // 
            // Frame2
            // 
            this.Frame2.BackColor = System.Drawing.SystemColors.Control;
            this.Frame2.Controls.Add(this.optAllInSameFolder);
            this.Frame2.Controls.Add(this.optUseMultipleProfiles);
            this.Frame2.Controls.Add(this.optFolderPreProfile);
            this.Frame2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.Frame2.ForeColor = System.Drawing.SystemColors.ControlText;
            this.Frame2.Location = new System.Drawing.Point(8, 8);
            this.Frame2.Name = "Frame2";
            this.Frame2.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.Frame2.Size = new System.Drawing.Size(576, 87);
            this.Frame2.TabIndex = 0;
            this.Frame2.TabStop = false;
            this.Frame2.Text = "Select destination structure";
            // 
            // optAllInSameFolder
            // 
            this.optAllInSameFolder.BackColor = System.Drawing.SystemColors.Control;
            this.optAllInSameFolder.Cursor = System.Windows.Forms.Cursors.Default;
            this.optAllInSameFolder.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.optAllInSameFolder.ForeColor = System.Drawing.SystemColors.ControlText;
            this.optAllInSameFolder.Location = new System.Drawing.Point(8, 16);
            this.optAllInSameFolder.Name = "optAllInSameFolder";
            this.optAllInSameFolder.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.optAllInSameFolder.Size = new System.Drawing.Size(373, 26);
            this.optAllInSameFolder.TabIndex = 0;
            this.optAllInSameFolder.TabStop = true;
            this.optAllInSameFolder.Text = "Export all documents using the same document profile";
            this.optAllInSameFolder.UseVisualStyleBackColor = false;
            this.optAllInSameFolder.CheckedChanged += new System.EventHandler(this.optAllInSameFolder_CheckedChanged);
            // 
            // optUseMultipleProfiles
            // 
            this.optUseMultipleProfiles.BackColor = System.Drawing.SystemColors.Control;
            this.optUseMultipleProfiles.Cursor = System.Windows.Forms.Cursors.Default;
            this.optUseMultipleProfiles.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.optUseMultipleProfiles.ForeColor = System.Drawing.SystemColors.ControlText;
            this.optUseMultipleProfiles.Location = new System.Drawing.Point(8, 58);
            this.optUseMultipleProfiles.Name = "optUseMultipleProfiles";
            this.optUseMultipleProfiles.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.optUseMultipleProfiles.Size = new System.Drawing.Size(415, 25);
            this.optUseMultipleProfiles.TabIndex = 2;
            this.optUseMultipleProfiles.Text = "Export all document profiles";
            this.optUseMultipleProfiles.UseVisualStyleBackColor = false;
            // 
            // optFolderPreProfile
            // 
            this.optFolderPreProfile.BackColor = System.Drawing.SystemColors.Control;
            this.optFolderPreProfile.Checked = true;
            this.optFolderPreProfile.Cursor = System.Windows.Forms.Cursors.Default;
            this.optFolderPreProfile.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.optFolderPreProfile.ForeColor = System.Drawing.SystemColors.ControlText;
            this.optFolderPreProfile.Location = new System.Drawing.Point(8, 36);
            this.optFolderPreProfile.Name = "optFolderPreProfile";
            this.optFolderPreProfile.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.optFolderPreProfile.Size = new System.Drawing.Size(415, 25);
            this.optFolderPreProfile.TabIndex = 1;
            this.optFolderPreProfile.TabStop = true;
            this.optFolderPreProfile.Text = "Export each document profile as separate document library";
            this.optFolderPreProfile.UseVisualStyleBackColor = false;
            // 
            // tabPage3
            // 
            this.tabPage3.Controls.Add(this.rtb_EventLog);
            this.tabPage3.Controls.Add(this.btnStart);
            this.tabPage3.Controls.Add(this.btnClose);
            this.tabPage3.Location = new System.Drawing.Point(4, 22);
            this.tabPage3.Name = "tabPage3";
            this.tabPage3.Size = new System.Drawing.Size(592, 334);
            this.tabPage3.TabIndex = 2;
            this.tabPage3.Text = "Export";
            // 
            // rtb_EventLog
            // 
            this.rtb_EventLog.BorderStyle = System.Windows.Forms.BorderStyle.None;
            this.rtb_EventLog.Location = new System.Drawing.Point(16, 8);
            this.rtb_EventLog.Name = "rtb_EventLog";
            this.rtb_EventLog.Size = new System.Drawing.Size(568, 288);
            this.rtb_EventLog.TabIndex = 22;
            this.rtb_EventLog.Text = "Waiting...";
            // 
            // btnStart
            // 
            this.btnStart.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
            this.btnStart.BackColor = System.Drawing.SystemColors.HotTrack;
            this.btnStart.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnStart.ForeColor = System.Drawing.SystemColors.Menu;
            this.btnStart.Location = new System.Drawing.Point(488, 304);
            this.btnStart.Name = "btnStart";
            this.btnStart.Size = new System.Drawing.Size(96, 24);
            this.btnStart.TabIndex = 21;
            this.btnStart.Text = "&Start Export";
            this.btnStart.UseVisualStyleBackColor = false;
            this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
            // 
            // btnClose
            // 
            this.btnClose.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
            this.btnClose.BackColor = System.Drawing.SystemColors.HotTrack;
            this.btnClose.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.btnClose.ForeColor = System.Drawing.SystemColors.Info;
            this.btnClose.Location = new System.Drawing.Point(16, 304);
            this.btnClose.Name = "btnClose";
            this.btnClose.Size = new System.Drawing.Size(96, 24);
            this.btnClose.TabIndex = 20;
            this.btnClose.Text = "Close";
            this.btnClose.UseVisualStyleBackColor = false;
            this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
            // 
            // groupBox3
            // 
            this.groupBox3.Controls.Add(this.rdReportAll);
            this.groupBox3.Controls.Add(this.rdReportWarnings);
            this.groupBox3.Controls.Add(this.rdReportErrors);
            this.groupBox3.Location = new System.Drawing.Point(10, 190);
            this.groupBox3.Name = "groupBox3";
            this.groupBox3.Size = new System.Drawing.Size(574, 88);
            this.groupBox3.TabIndex = 69;
            this.groupBox3.TabStop = false;
            this.groupBox3.Text = "Reporting";
            // 
            // rdReportAll
            // 
            this.rdReportAll.Checked = true;
            this.rdReportAll.Location = new System.Drawing.Point(16, 17);
            this.rdReportAll.Name = "rdReportAll";
            this.rdReportAll.Size = new System.Drawing.Size(104, 24);
            this.rdReportAll.TabIndex = 0;
            this.rdReportAll.TabStop = true;
            this.rdReportAll.Text = "Report All ";
            // 
            // rdReportWarnings
            // 
            this.rdReportWarnings.Location = new System.Drawing.Point(16, 41);
            this.rdReportWarnings.Name = "rdReportWarnings";
            this.rdReportWarnings.Size = new System.Drawing.Size(192, 24);
            this.rdReportWarnings.TabIndex = 1;
            this.rdReportWarnings.Text = "Report Warnings and Errors";
            // 
            // rdReportErrors
            // 
            this.rdReportErrors.Location = new System.Drawing.Point(16, 65);
            this.rdReportErrors.Name = "rdReportErrors";
            this.rdReportErrors.Size = new System.Drawing.Size(104, 17);
            this.rdReportErrors.TabIndex = 2;
            this.rdReportErrors.Text = "Report Errors";
            // 
            // cmbDocumentProfiles
            // 
            this.cmbDocumentProfiles.Enabled = false;
            this.cmbDocumentProfiles.FormattingEnabled = true;
            this.cmbDocumentProfiles.Location = new System.Drawing.Point(157, 163);
            this.cmbDocumentProfiles.Name = "cmbDocumentProfiles";
            this.cmbDocumentProfiles.Size = new System.Drawing.Size(206, 21);
            this.cmbDocumentProfiles.TabIndex = 14;
            this.cmbDocumentProfiles.Text = "urn:content-class:basedocument";
            // 
            // btnPopulate
            // 
            this.btnPopulate.Enabled = false;
            this.btnPopulate.Location = new System.Drawing.Point(370, 163);
            this.btnPopulate.Name = "btnPopulate";
            this.btnPopulate.Size = new System.Drawing.Size(75, 23);
            this.btnPopulate.TabIndex = 15;
            this.btnPopulate.Text = "&Populate";
            this.btnPopulate.UseVisualStyleBackColor = true;
            this.btnPopulate.Click += new System.EventHandler(this.btnPopulate_Click);
            // 
            // frmExporter
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(608, 494);
            this.Controls.Add(this.tabControl1);
            this.Controls.Add(this.TopBanner);
            this.Controls.Add(this.Picture1);
            this.Name = "frmExporter";
            this.Text = "SharePoint 2001 data extractor";
            this.Load += new System.EventHandler(this.MainApp_Load);
            ((System.ComponentModel.ISupportInitialize)(this.Picture1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.TopBanner)).EndInit();
            this.tabControl1.ResumeLayout(false);
            this.tabPage1.ResumeLayout(false);
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.tabPage2.ResumeLayout(false);
            this.tabPage2.PerformLayout();
            this.Frame2.ResumeLayout(false);
            this.tabPage3.ResumeLayout(false);
            this.groupBox3.ResumeLayout(false);
            this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new frmExporter());
		}

		private void MainApp_Load(object sender, System.EventArgs e)
		{
			WindowsPrincipal wp = new WindowsPrincipal(WindowsIdentity.GetCurrent());
			
			if(txtOwner.Text.Length==0)
				txtOwner.Text=wp.Identity.Name;
			if(File.Exists(Application.StartupPath+ "\\config.xml"))
			{
				try
				{
					// Create an instance of the XmlSerializer specifying type.
					XmlSerializer serializer = new XmlSerializer(typeof(@params));
					// Create a TextReader to read the file. 
					FileStream fs = new FileStream(Application.StartupPath+ "\\config.xml", FileMode.Open);
					TextReader reader = new StreamReader(fs);
      
					// Declare an object variable of the type to be deserialized.
					@params p;

					// Use the Deserialize method to restore the object's state.
					p = (@params) serializer.Deserialize(reader);
					txtDirPath.Text=p.Directory;
					txtEMail.Text=p.Email;
					txtOwner.Text=p.Owner;
					cmbDocumentProfiles.Text=p.ProfileToUse;
					txtSPS2001RootFolder.Text=p.RootFolder;
					txtSiteDefinitionName.Text=p.SiteDefinitionName;
					txtWorkSpace.Text=p.WorkSpace;
					optAllInSameFolder.Checked=bool.Parse(p.AllInSameFolder);
					optFolderPreProfile.Checked=bool.Parse(p.FolderPerProfile);
                    if (!optAllInSameFolder.Checked && !optFolderPreProfile.Checked)
                        optUseMultipleProfiles.Checked = true;
					chkMigrateVersions.Checked=bool.Parse(p.MigrateVersions);
					cmbRoot.Text=p.SiteContainerRoot;
                    txtSiteName.Text = p.SiteName;

					fs.Close();

				}
				catch(Exception Ex)
				{
				}
			}

		}


		private void btnStart_Click(object sender, System.EventArgs e)
		{
			try
			{
                ErrorLevel level = ErrorLevel.Information;
                if (rdReportWarnings.Checked)
                    level = ErrorLevel.Warning;
                else if (rdReportErrors.Checked)
                    level = ErrorLevel.Error;

				rtb_EventLog.Clear();
                if (!Directory.Exists(txtDirPath.Text))
                {
                    Directory.CreateDirectory(txtDirPath.Text);
                }
				Logger.Init(txtDirPath.Text+"\\Export" + DateTime.Now.ToString("MMddHHmm") + ".log",level);
				Logger.LogDataSendingEvent += new Logger.LogDataEventHandler(this.IncomingEventLogData);

				SharePoint.ImportExport.ExportSPS2001.ExportData.Handler exporter=new Handler();
				exporter.WorkspaceName=txtWorkSpace.Text;
				exporter.ExportDirectoryName=txtDirPath.Text;
				exporter.ExportFolderName=txtSPS2001RootFolder.Text;
				exporter.ExportVersions=chkMigrateVersions.Checked;
				exporter.Owner=txtOwner.Text;
				exporter.Email=txtEMail.Text;
                exporter.SiteName = txtSiteName.Text;
				exporter.SiteDefinitionName=txtSiteDefinitionName.Text;
				exporter.RootContainerName=cmbRoot.Text;
				exporter.ImportSiteType=SiteType.Site;
                exporter.ProfileToUse = ""; 
                if (optAllInSameFolder.Checked)
                {
                    exporter.FolderCreationOptions = FolderCreationOptionsEnum.AllInSameFolder;
                    exporter.ProfileToUse = cmbDocumentProfiles.Text;
                }
                if (optFolderPreProfile.Checked)
                    exporter.FolderCreationOptions = FolderCreationOptionsEnum.AFolderPerProfile;
                if (optUseMultipleProfiles.Checked)
                    exporter.FolderCreationOptions = FolderCreationOptionsEnum.MultipleProfilesInSameFolder;
				if(exporter.Process())
				{
				}
				Logger.LogDataSendingEvent -= new Logger.LogDataEventHandler(this.IncomingEventLogData);

//				object vEmpty = Missing.Value;
//		
//				PKMCDO.KnowledgeWorkspace workSpace=new PKMCDO.KnowledgeWorkspaceClass();
//				PKMCDO.KnowledgeFolder KMFolder = new PKMCDO.KnowledgeFolder();
//
//				KMFolder.DataSource.Open(txtWorkSpace.Text+"/Documents",null, PKMCDO.ConnectModeEnum.adModeReadWrite,PKMCDO.RecordCreateOptionsEnum.adFailIfNotExists, PKMCDO.RecordOpenOptionsEnum.adOpenSource, "", ""); 
//
//
//				Array coordinators = (Array)KMFolder.Coordinators; 
//
//
//				Array authors = (Array)KMFolder.Authors; 
//
//
//				foreach(string coordinator in coordinators) 
//
//
//					MessageBox.Show(coordinator); 
//
//
//				foreach(string member in authors) 
//
//
//					MessageBox.Show(member); 
//
//
//
//				workSpace.DataSource.Open(txtWorkSpace.Text,null, PKMCDO.ConnectModeEnum.adModeReadWrite,PKMCDO.RecordCreateOptionsEnum.adFailIfNotExists,PKMCDO.RecordOpenOptionsEnum.adOpenSource,"","");
//				MessageBox.Show( workSpace.DisplayName);
			}		
			catch(Exception Ex)
			{
				MessageBox.Show( Ex.Message);
			}
		
		}

		private void btnClose_Click(object sender, System.EventArgs e)
		{
			DialogResult result = MessageBox.Show("Are you sure you'd like to exit?", "Close Application", MessageBoxButtons.YesNo,MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,MessageBoxOptions.DefaultDesktopOnly);
			if(result == DialogResult.Yes)
			{
				try 
				{
					NewDataSet ds = new NewDataSet();
					@params p=new @params();
					
					p.Directory=txtDirPath.Text;
					p.Email=txtEMail.Text;
					p.Owner=txtOwner.Text;
					p.ProfileToUse=cmbDocumentProfiles.Text;
					p.RootFolder=txtSPS2001RootFolder.Text;
					p.SiteDefinitionName=txtSiteDefinitionName.Text;
					p.WorkSpace=txtWorkSpace.Text;
					p.AllInSameFolder=(optAllInSameFolder.Checked.ToString());
					p.FolderPerProfile=optFolderPreProfile.Checked.ToString();
					p.MigrateVersions=chkMigrateVersions.Checked.ToString();
					p.SiteContainerRoot=cmbRoot.Text;
                    p.SiteName = txtSiteName.Text;
					XmlSerializer serializer = new XmlSerializer(typeof(@params));
					/* Create a StreamWriter to write with. First create a FileStream
				 object, and create the StreamWriter specifying an Encoding to use. */
					FileStream fs = new FileStream(Application.StartupPath+"\\config.xml", FileMode.Create);
					TextWriter writer = new StreamWriter(fs, new UTF8Encoding());
					// Serialize using the XmlTextWriter.
					serializer.Serialize(writer, p);
					writer.Close();


						
				}
				catch(IOException Ex)
				{
					Logger.Log(ErrorLevel.Information,"Could not write to config.xml. Error:"+Ex.Message );
				}
				this.Close();
			}
			

		}
        private void lineFormatter(ErrorLevel level)
        {
            System.Drawing.Font currentFont = rtb_EventLog.SelectionFont;
            System.Drawing.FontStyle newFontStyle;

            switch (level)
            {
                case ErrorLevel.Error: // critical
                    newFontStyle = FontStyle.Bold;
                    rtb_EventLog.SelectionColor = Color.Red;
                    break;
                case ErrorLevel.Warning:  // warning
                    newFontStyle = FontStyle.Regular;
                    rtb_EventLog.SelectionColor = Color.Red;
                    break;
                    break;
                default:
                    rtb_EventLog.SelectionColor = Color.Black;
                    newFontStyle = FontStyle.Regular;
                    break;
                // regular output
            }

            rtb_EventLog.SelectionFont = new Font(
            currentFont.FontFamily,
            currentFont.Size,
            newFontStyle);

        }

        /// <summary>
        /// RichTextBox Event Logger component
        /// </summary>
        public void addTextToLogRtf(string IncomingLogData)
        {
            try
            {
                string sLevel = IncomingLogData.Substring(0, IncomingLogData.IndexOf("-"));
                ErrorLevel level = (ErrorLevel)Enum.Parse(typeof(ErrorLevel), sLevel);
                lineFormatter(level);
                IncomingLogData = DateTime.Now.ToLongTimeString() + ":  " + IncomingLogData + "\n";


                //NOTE: replace rtf_eventlog with your RTF window, or text window, in your window app, to display log info.
                rtb_EventLog.AppendText(IncomingLogData);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error while trying to write events incoming to AddTextToLogRtf function, error:" + ex.Message + ", in location:" + ex.TargetSite);
            }
            finally
            {
            }
        }

		private void IncomingEventLogData(object sender, SPEventArgs e)
		{
			try
			{
				addTextToLogRtf(e.Message);
			}
			catch(Exception ex)
			{
				string errorString = "Error in trying to find AD presence, error:" + ex.Message + ", in module:" + ex.TargetSite;
				addTextToLogRtf(errorString);
				System.Diagnostics.Debug.WriteLine(errorString);
			}
			finally
			{
			}
		}

		private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		private void btnNext1_Click(object sender, System.EventArgs e)
		{
			tabControl1.SelectedIndex = 1;

		}

		private void btnNext2_Click(object sender, System.EventArgs e)
		{
		tabControl1.SelectedIndex = 2;
		}

		private void btnPick_Click(object sender, System.EventArgs e)
		{
			frmFolderPicker frm = new frmFolderPicker();
			frm.WorkspaceName=txtWorkSpace.Text;
			frm.startFrom=txtSPS2001RootFolder.Text;
			DialogResult result=frm.ShowDialog();
			if(result==DialogResult.OK)
			{
				txtSPS2001RootFolder.Text=frm.SelectedFolder;
			}
		}


		private void optAllInSameFolder_CheckedChanged(object sender, System.EventArgs e)
		{
			lblProfileToUse.Enabled=true;
			cmbDocumentProfiles.Enabled=true;
            btnPopulate.Enabled = true;
		
		}

        private void btnPopulate_Click(object sender, EventArgs e)
        {
            if (cmbDocumentProfiles.Items.Count < 1)
            {
                ConnectionClass Conn = new ConnectionClass();
                try
                {
                    Conn.ConnectionString = "provider=msdaipp.dso";
                    Conn.CommandTimeout = 0;
                    Conn.Open(txtWorkSpace.Text, null, null, 0);
                    PKMCDO.KnowledgeWorkspace workSpace = new PKMCDO.KnowledgeWorkspaceClass();
                    workSpace.DataSource.Open(txtWorkSpace.Text, Conn, PKMCDO.ConnectModeEnum.adModeReadWrite, PKMCDO.RecordCreateOptionsEnum.adFailIfNotExists, PKMCDO.RecordOpenOptionsEnum.adOpenSource, "", "");
                    System.Array contentClasses = (System.Array)workSpace.ContentClasses;
                    foreach (string contentClassName in contentClasses)
                    {
                        cmbDocumentProfiles.Items.Add(contentClassName);
                    }
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(workSpace);
                    btnPopulate.Enabled = false;
                }
                catch
                {
                }
                finally
                {
                    if (Conn.State == 1)
                        Conn.Close();

                }
            }


        }


	
	}
}
